package com.bhald.CJ.Adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bhald.CJ.Entity.LockEntity;
import com.bhald.CJ.lock.R;

public class SetLockAdapter extends BaseAdapter {

	private List<LockEntity> locklist;
	private Context context;
	private View view;
	private TextView list_item_gatewayname;

	public SetLockAdapter(List<LockEntity> locklist, Context context) {
		this.context = context;
		this.locklist = locklist;
	}

	@Override
	public int getCount() {
		return locklist.size();
	}

	@Override
	public Object getItem(int arg0) {
		return locklist.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			view = LayoutInflater.from(context).inflate(R.layout.set_layout_main_gateway_list_item, null);
		} else {
			view = convertView;
		}

		LockEntity lock = locklist.get(position);

		LinearLayout nextarrowimage = (LinearLayout) view.findViewById(R.id.nextarrowimage);
		nextarrowimage.setVisibility(4);

		list_item_gatewayname = (TextView) view.findViewById(R.id.list_item_gatewayname);

		list_item_gatewayname.setText(lock.getGateway() +  " > "+ lock.getLockName());

		return view;
	}
}
